<template>
<t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
    </t-image-viewer>
    <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
    </van-image-preview>
  <div class="outline-parent " >
    
    <div 
      class="content-parent border-hover-style"
      :style="{ backgroundImage: `url(${publicUrls + 'free/style3/Auxiliaryoutlinestyle1Bg.webp'})` }"
    >
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div
        class="content content1"
        v-if="(props.info.value || (props.info.video && props.info.video.url)) && props.info.remarks"
      >
        <div
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
        >
          <i class="doorIcon">&#xe688;</i>
        </div>
        <div class="img-box">
          <!-- <img src="" alt=""  /> -->
          <videoview
            @click="audioplay(false)"
            :info="props.info"
            v-if="props.info.video && props.info.video.url"
          ></videoview>
          <img
            v-else
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/format/webp'"
            alt=""
          />
          <div class="radio1 radio"></div>
          <div class="radio2 radio"></div>
          <div class="radio3 radio"></div>
          <div class="radio4 radio"></div>
        </div>
        <div class="content-right">
          <div class="title-box">
            {{ props.info.text }}
          </div>
          <p class="subtitle">
            {{ props.info.subTitle }}
          </p>
          <img class="solid" :src="publicUrls + 'free/style3/Auxiliaryoutlinestyle1xt11255.webp'" alt="" />
          <div class="remarks" v-if="props.info.remarks">
            <TextMax
              :infoData="props.info"
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :row="3"
            ></TextMax>
          </div>
        </div>
      </div>
      <div class="content content2" v-else>
        <div
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
        >
          <i class="doorIcon">&#xe688;</i>
        </div>
        <div class="title-box" :class="{ 'title-box1': !props.info.subTitle }">
          {{ props.info.text }}
        </div>   
        <p class="subtitle" v-if="props.info.subTitle">
          {{ props.info.subTitle }}
        </p>
        <img class="solid" :src="publicUrls + 'free/style3/Auxiliaryoutlinestyle1xt.webp'" alt="" />
        <div class="remarks" v-if="props.info.remarks">
          <TextMax
            :infoData="props.info"
            v-if="props.domShow"
            :data="props.info.remarks"
            :title="props.info.text"
            :row="4"
          ></TextMax>
        </div>
        <div class="img-box" :class="{ 'img-box2': props.info.subTitle }" v-if="props.info.value || (props.info.video && props.info.video.url)">
          <!-- <img src="" alt=""  /> -->
          <videoview
            @click="audioplay(false)"
            :info="props.info"
            v-if="props.info.video && props.info.video.url"
          ></videoview>
          <img
          v-else
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/format/webp'"
            alt=""
          />
          <div class="radio1 radio"></div>
          <div class="radio2 radio"></div>
          <div class="radio3 radio"></div>
          <div class="radio4 radio"></div>
        </div>
      </div>
    </div>
    <!-- <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio> -->
  </div>
</template>



<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax3.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  display: flex;
  // align-items: flex-end;
  position: relative;
  margin-top: 0;
  height: 100%;
  margin-right: 140px;
}
.content-parent {
  position: relative;
  margin-top: 80px;
  width: 820px;
  height: 432px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
   -webkit-box-reflect: below 60% linear-gradient(transparent, rgba(0, 0, 0, 0.1));
}
.content {
  position: relative;
  display: flex;
  width: 704px;
  height: 320px;
  margin-left: 56px;
}
.content1 {
  display: flex;
  margin-top: 56px;
  .img-box {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    width: 352px;
    height: 320px;
    background: #623333;
    margin-right: 32px;
    // border-radius: 8px;
  }
  .outline-cover {
    height: 320px;
    width: auto;
    object-fit: contain;
    transition: all 0.3s;
  }
  .outline-cover:hover {
    transform: scale(1.2);
  }
  .radio {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e1dbcf;
    z-index: 6;
  }
  .radio1 {
    top: -8px;
    left: -8px;
  }
  .radio2 {
    top: -8px;
    right: -8px;
  }
  .radio3 {
    bottom: -8px;
    left: -8px;
  }
  .radio4 {
    bottom: -8px;
    right: -8px;
  }
  .content-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    .title-box {
      width: 100%;
      font-family: SourceBold;
      font-size: 20px;
      color: #2f1b16;
      line-height: 30px;
      margin-top: 16px;
      text-align: center;
    }
    .subtitle {
      width: 320px;
      height: 48px;
      font-family: SourceMedium;
      font-size: 18px;
      color: #2f1b16;
      line-height: 24px;
      text-align: center;
      opacity: 0.5;
      margin-top: 8px;
    }
    .solid {
      width: 100%;
      height: auto;
      margin-top: 26px;
    }
    .remarks {
      margin-top: 24px;
      width: 100%;
    }
  }
}
.audio-box {
  position: absolute;
  bottom: 0px;
  right: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #ece5d9;
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  border: 2px solid #623333;
  border-radius: 50%;
  .doorIcon {
    font-size: 24px;
    color: rgba(98, 51, 51, 1);
  }
  z-index: 22;
}
.content2 { 
  .audio-box {
    bottom: none;
    top: -20px;
  }
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 72px;
  margin-left: 56px;
  width: auto;
  margin-right: 66px;
  .title-box {
    width: 100%;
    font-family: SourceBold;
    font-size: 20px;
    color: #2f1b16;
    line-height: 30px;
    margin-top: 0px;
    text-align: center;
  }
  .title-box1 {
    // margin-top: 24px;
  }
  .subtitle {
    width: 100%;
    height: 24px;
    font-family: SourceMedium;
    font-size: 18px;
    color: #2f1b16;
    line-height: 24px;
    text-align: center;
    opacity: 0.5;
    margin-top: 8px;
  }
  .solid {
    width: 100%;
    height: auto;
    margin-top: 24px;
  }
  .remarks {
    margin-top: 24px;
    width: 100%;
  }
  .img-box {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    width: 704px;
    height: 224px; 
    background: #623333;
    margin-top: 0px;
    // border-radius: 8px;
  }
  .outline-cover {
    height: 224px; 
    width: auto;
    object-fit: contain;
    transition: all 0.3s;
  }
  .img-box2 {
    height: 180px;
    .outline-cover {
      height: 180px;
    }
  }
  .outline-cover:hover {
    transform: scale(1.2);
  }
  .radio {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e1dbcf;
    z-index: 6;
  }
  .radio1 {
    top: -8px;
    left: -8px;
  }
  .radio2 {
    top: -8px;
    right: -8px;
  }
  .radio3 {
    bottom: -8px;
    left: -8px;
  }
  .radio4 {
    bottom: -8px;
    right: -8px;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
</style>
